from Tkinter import *
from tkSimpleDialog import *
from project import *
import sys
from projectframe import *
import tkMessageBox

class MainWindow(Tk):
    """
    Represents the main window of the application.
    """
    
    def __init__(self, listener):
        Tk.__init__(self)
        self.listener = listener
        self.createMenu()
        self.frame = None
        
    def createMenu(self):
        menu = Menu(self)
        self.config(menu = menu)
        
        filemenu = Menu(menu)
        menu.add_cascade(label = 'Fichier', menu = filemenu)
        filemenu.add_command(label = 'Nouveau projet...', command = self._onCreateProject)
        filemenu.add_command(label = 'Ouvrir un projet...', command = self._onOpenProject)
        filemenu.add_separator()
        filemenu.add_command(label = 'Quitter', command = sys.exit)
        
        viewmenu = Menu(menu)
        menu.add_cascade(label = 'Affichage', menu = viewmenu)
        viewmenu.add_command(label = 'Projet', command = self._onShowProject)
        viewmenu.add_command(label = 'Membres', command = self._onShowProjectMembers)
        viewmenu.add_command(label = 'SCRUM', command = self._onShowProjectScrum)
        viewmenu.add_command(label = 'Analyse Textuelle', command = self._onShowProjectTextualAnalisys)
        viewmenu.add_command(label = 'CRC', command = self._onShowProjectCrc)

    def _onCreateProject(self):
        self.listener.onCreateProject()
        
    def _onOpenProject(self):
        self.listener.onOpenProject()
        
    def _onShowProject(self):
        self.listener.onShowProject()
        
    def _onShowProjectMembers(self):
        self.listener.onShowProjectMembers()
        
    def _onShowProjectScrum(selfself):
        pass
    
    def _onShowProjectTextualAnalisys(self):
        pass
    
    def _onShowProjectCrc(self):
        pass

    def destroyFrame(self):
        if self.frame != None:
            self.frame.unpack()
            self.frame.destroy()
            self.frame = None
            
    def setFrame(self, frame):
        self.destroyFrame()
        self.frame = frame
        self.frame.pack()